#include "Configurator.h"
#include <list>
#include <map>
#include <string>

#ifndef SOLVER_H_
#define SOLVER_H_

using namespace std;

class Solver
{
public:
	Solver(Configurator* configurator);
	void Solve();
	void Finish(double time);
	
private:
	Configurator* dwarfConfigurator;
	int *threadBounds;						 // boundary indexes of string part of each omp-proccess
	
	map<string, int> stringTotal;			 // final dictionary for counting the entries of chars in the content

	int contentSize;						 // size of *mainContent
	char *mainContent;						 // content for parsing
	string TransformCharFragment(int begin, int end);
	void GetContent();
	void InitParallelization(int threadCount);
	void Map(list<string> &partialStringEntries, int threadNumber);
	void Reduce(map<string, int> &partialStringTotal, list<string> &partialStringEntries);
	void SumThreadResult(map<string, int> &partialStringTotal);
};

#endif